package cn.com.yitong.app.crm.esearch.sql4es.http;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;

public class Test {
	
	public static void main(String[] args) throws SQLException {
		EsHttpClient mEsHttpClient = new EsHttpClient(EsHttpConfig.getEsConfig("ceshi002"));
		//添加es索引
//		System.out.println(mEsHttpClient.addEsIndex());
		//删除es索引
//		System.out.println(mEsHttpClient.deleteEsIndex());
		//添加数据
		addDate(mEsHttpClient);
	}
	//es添加数据
	static void addDate(EsHttpClient mEsHttpClient) throws SQLException{
		List<Map<String,Object>> listmap = new ArrayList<>();
		for (int i = 0; i < 10; i++) {
			Map<String,Object> mmap = new HashMap<>();
			mmap.put("name", "张三"+i);
			mmap.put("age", "2"+i);
			mmap.put("pk_id", i+"");
			listmap.add(mmap);
		}
	
		
		System.out.println(mEsHttpClient.addList(listmap,"pk_id"));
	}

}
